﻿<Window x:Class="ExcelMergeDocs.WinClient.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Excel Document Merger" Height="350" Width="525"
        DataContext="{Binding Main, Source={StaticResource Locator}}"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
        xmlns:local="clr-namespace:ExcelMergeDocs.WinClient.ViewModel"
        xmlns:extToolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit.Extended"

        >
    <Window.Resources>
        <Style TargetType="{x:Type TreeViewItem}">
            <Setter Property="IsExpanded" Value="{Binding RelativeSource={RelativeSource Self}, Path=Header.IsExpanded,Mode=TwoWay}"/>
        </Style>

        <HierarchicalDataTemplate DataType="{x:Type local:DocViewModel}"
                                  ItemsSource="{Binding Path=Worksheets}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <CheckBox IsChecked="{Binding IsSelected}" Margin="2"/>
                <TextBlock Grid.Column="1" Text="{Binding Name}" Margin="2" />
            </Grid>
        </HierarchicalDataTemplate>
        <DataTemplate DataType="{x:Type local:WSViewModel}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <CheckBox IsChecked="{Binding IsSelected}" Margin="2"/>
                <TextBlock Grid.Column="1" Text="{Binding Name}" Margin="2" />
            </Grid>
        </DataTemplate>
    </Window.Resources>
    <Grid>
        <extToolkit:BusyIndicator IsBusy="{Binding Path=IsBusy}" >

            <DockPanel AllowDrop="True">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Drop">
                        <cmd:EventToCommand Command="{Binding FileDroppedCommand, Mode=OneWay}" PassEventArgsToCommand="True"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
                <Grid DockPanel.Dock="Top">
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Menu>
                        <MenuItem Header="_Clear" Command="{Binding ClearAllCommand}" />
                        <MenuItem Header="_Process" Command="{Binding ProcessCommand}" />
                    </Menu>
                    <Label Grid.Row="1">
                        Drag and drop files to begin
                    </Label>
                </Grid>
                <TreeView ItemsSource="{Binding Documents}"/>
            </DockPanel>
        </extToolkit:BusyIndicator>
    </Grid>
</Window>
